<?php 
// 在每个受保护页面的开始加上以下代码
session_start();
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
    header('Location: index.php'); // 重定向到登录页面
    exit;
}
// ...页面的其余内容


?>
<form action="index.php?action=logout" method="post">
    <p>
        <input type="submit" value="注销">
    </p>
</form>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Send POST Request</title>
    <script src="/ai-post/js/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $("#getCate").click(function(){
				var my_url = $('#url').val();
				var my_key = $('#key').val();
				var postData = {
					'my_url': my_url,
					'Token': my_key,
					'Methods': 'getCategory',
                };

                $.ajax({
                    url: my_url+'/e/extend/aiPostPublish/index.php', // This is the url that will be proxied to ccc.com/api/mypost.php
					//url: '/api/ccc.com/mypost.php', // This is the url that will be proxied to ccc.com/api/mypost.php
                    type: 'POST',
                    data: JSON.stringify(postData),
					contentType: "application/json",
                    success: function(response) {
                        // Handle success
                        console.log(response);
                        $("#result").text(response);
                    },
                    error: function(xhr, status, error) {
                        // Handle error
                        console.error(error);
                        $("#result").text("Error: " + error);
                    }
                });
            });
        });
    </script>
</head>
<body>
	网址：<input type="text" id="url" value="http://ccc.com" placeholder="https://或者http://,结尾不加/">
    密钥：<input type="text" id="key" value="IjUN6LYeQwud2FD6">
    <button id="getCate">同步栏目</button>
    <button id="saveCate">保存</button>
    
    <div id="result"></div>
</body>
</html>
